import { Tooltip } from 'antd';
import { tableSorter, tooltipLength, renderTableText } from '@/utils';
import pageStyles from '@/common/pageLayout.less';
import { DictionaryRenderFun, formatDecimal } from '../../Acommon';

import moment from 'moment';

// 资产Table表格的配置
const assetTableColumnOA = () => {
  const columnConfig: any = [
    {
      title: '资产编号',
      dataIndex: 'assetCode',
      key: 'assetCode',
      width: 160,
      fixed: 'left',
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.assetCode > b.assetCode ? 1 : -1),
      render: (text: string, record: Record<string, any>) => {
        return (
          <Tooltip title={tooltipLength(text, 50)}>
            <span>{text || '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '资产名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 160,
      fixed: 'left',
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      render: (text: string, record: Record<string, any>) => {
        return (
          <Tooltip title={tooltipLength(text, 50)}>
            <span>{text || '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '资产分类',
      dataIndex: 'assetClassName',
      key: 'assetClassName',
      width: 120,
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.assetClassName > b.assetClassName ? 1 : -1),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => (a.brandType > b.brandType ? 1 : -1),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '规格型号',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => (a.paramsInfo > b.paramsInfo ? 1 : -1),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '状态',
      dataIndex: 'assetStateName',
      key: 'assetStateName',
      width: 110,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStateName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '供应商',
      dataIndex: 'supplier',
      key: 'supplier',
      width: 150,
      // ishidden: (queryType == '2' ? true : false),
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'supplier'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => (a.quantityOrArea > b.quantityOrArea ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurementName',
      key: 'unitOfMeasurementName',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => (a.unitOfMeasurement > b.unitOfMeasurement ? 1 : -1),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '资产原值（元）',
      dataIndex: 'totalValue',
      key: 'totalValue',
      width: 170,
      visible: true,
      sorter: (a: any, b: any) => (a.totalValue > b.totalValue ? 1 : -1),
      render: (text: string | number) => formatDecimal(text),
    },
    {
      title: '使用人',
      dataIndex: 'userName',
      key: 'userName',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => (a.userName > b.userName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    // {
    //   title: '选择仓库',
    //   dataIndex: 'assetStoreName',
    //   key: 'assetStoreName',
    //   width: 220,
    //   visible: false,
    //   fixed: 'right',
    // },
    // {
    //   title: '管理部门',
    //   dataIndex: 'assetDepartmentName',
    //   key: 'assetDepartmentName',
    //   width: 120,
    //   visible: true,
    //   sorter: (a: any, b: any) => (a.assetDepartmentName > b.assetDepartmentName ? 1 : -1),
    //   render: (text: string) => {
    //     return (
    //       <Tooltip title={text}>
    //         <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
    //       </Tooltip>
    //     );
    //   },
    // },
    // {
    //   title: '管理人',
    //   dataIndex: 'asseterName',
    //   key: 'asseterName',
    //   width: 120,
    //   visible: true,
    //   sorter: (a: any, b: any) => (a.asseterName > b.asseterName ? 1 : -1),
    //   render: (text: string) => {
    //     return (
    //       <Tooltip title={text}>
    //         <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
    //       </Tooltip>
    //     );
    //   },
    // },
    // {
    //   title: '取得方式',
    //   dataIndex: 'obtainTypeName',
    //   key: 'obtainTypeName',
    //   width: 120,
    //   ellipsis: {
    //     showTitle: true,
    //   },
    //   visible: true,
    //   unDrag: true,
    //   sorter: (a: any, b: any) => (a.obtainTypeName > b.obtainTypeName ? 1 : -1),
    //   render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    // },
    // {
    //   title: '取得时间',
    //   dataIndex: 'obtainDate',
    //   key: 'obtainDate',
    //   width: 150,
    //   visible: false,
    //   sorter: (a: any, b: any) => (a.enterStoreTime > b.enterStoreTime ? 1 : -1),
    //   render: (text: string) => {
    //     return text ? moment(text).format('YYYY-MM-DD') : '--';
    //   },
    // },
    // {
    //   title: '合同编号',
    //   dataIndex: 'contractCode',
    //   key: 'contractCode',
    //   width: 120,
    //   ellipsis: {
    //     showTitle: true,
    //   },
    //   visible: true,
    //   unDrag: true,
    //   sorter: (a: any, b: any) => (a.contractCode > b.contractCode ? 1 : -1),
    //   render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    // },
    // {
    //   title: '财务入账状态',
    //   dataIndex: 'entryStateName',
    //   key: 'entryStateName',
    //   width: 150,
    //   ellipsis: {
    //     showTitle: true,
    //   },
    //   visible: true,
    //   unDrag: true,
    //   sorter: (a: any, b: any) => (a.entryStateName > b.entryStateName ? 1 : -1),
    //   render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    // },
  ];

  return columnConfig;
};

export { assetTableColumnOA };
